﻿using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DormMS.IService;
using DormMS.IService.Common;
using DormMS.Service;
using DormMS.Service.Common;

namespace WeChat
{
    public class Bootstrapper
    {

        public static IUnityContainer Initialise()
        {
            var container = BuildUnityContainer();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));

            return container;
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();

            // register all your components with the container here
            // it is NOT necessary to register your controllers

            // e.g. container.RegisterType<ITestService, TestService>();    
            RegisterTypes(container);

            return container;
        }

        public static void RegisterTypes(IUnityContainer container)
        {

            container.RegisterType<IOrderService, OrderService>();
            container.RegisterType<IUserGroupService, UserGroupService>();
            container.RegisterType<IUserGroupRoleService, UserGroupRoleService>();
            container.RegisterType<IMemberService, MemberService>();
            container.RegisterType<ICommonAreaService, CommonAreaService>();
            container.RegisterType<IFreightService, FreightService>();
            container.RegisterType<IProductCategoryService, ProductCategoryService>();
            container.RegisterType<ISpecService, SpecService>();
            container.RegisterType<IProductService, ProductService>();
            container.RegisterType<ICouponService, CouponService>();
            container.RegisterType<ISystemService, SystemService>();
            container.RegisterType<IShopService, ShopService>();
            container.RegisterType<ISpikeService, SpikeService>();
            container.RegisterType<ICarouselService, CarouselService>();
            container.RegisterType<ISpecialTopicService, SpecialTopicService>();
            container.RegisterType<IWxConfigService, WxConfigService>();
            container.RegisterType<IExchangeService, ExchangeService>();
            container.RegisterType<IActivityService, ActivityService>();//一分钱活动
            container.RegisterType<IActivityTeam, ActivityTeam>();//一分钱活动
            container.RegisterType<IActivityTeamMembersService, ActivityTeamMembersService>();//一分钱活动
            container.RegisterType<IDropGroupService, DropGroupService>();//降拼活动
            container.RegisterType<IGroupHeadService, GroupHeadService>();//降拼活动
            container.RegisterType<IDrawService, DrawService>();//积分抽奖
            container.RegisterType<IDrawDormMSService, DrawDormMSService>();
            container.RegisterType<ILogService, LogService>();//日志
            container.RegisterType<IActivityRuleService, ActivityRuleService>();//活动规则
        }
    }
}